﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

namespace VSSDKAssist.Platform.OptionPages
{
	public partial class GeneralOptionPageControl : UserControl
	{
		private const string EnableVSIPLoggingKey = @"Software\Microsoft\VisualStudio\8.0\General";
		private const string EnableVSIPLogging = "EnableVSIPLogging";

		public GeneralOptionPageControl()
		{
			InitializeComponent();
		}

		#region Properties
		private GeneralOptionPage optionPage;

		public GeneralOptionPage OptionPage
		{
			get
			{
				return optionPage;
			}
			set
			{
				optionPage = value;
			}
		}
		#endregion

		private void GeneralOptionPageControl_Load(object sender, EventArgs e)
		{
			this.chkEnableVSIPLogging.Checked = OptionPage.EnableVSIPLogging;
		}

		private void chkEnableVSIPLogging_CheckedChanged(object sender, EventArgs e)
		{
			OptionPage.EnableVSIPLogging = this.chkEnableVSIPLogging.Checked;

			RegistryKey key = Registry.CurrentUser.OpenSubKey(EnableVSIPLoggingKey, true);

			if(key != null)
			{
				if(chkEnableVSIPLogging.Checked)
				{
					key.SetValue(EnableVSIPLogging, 1, RegistryValueKind.DWord);
				}
				else
				{
					key.SetValue(EnableVSIPLogging, 0, RegistryValueKind.DWord);
				}
			}
		}
	}
}